<?php


namespace App\Services;

use App\DTOS\Admin\RoleDTO;
use App\Models\Role;

class RoleService
{
    public function paginate(RoleDTO $dto){
        $page = $dto->getPage();
        $pageSize = 50;
        $model = Role::query();

        return $model->paginate($pageSize,'*','page',$page);
    }

    public function add($data)
    {
        $model = Role::query();
        $data['guard_name'] = 'admin';
        $data['created_at'] = now();
        return $model->insertGetId($data);
    }

    public function updateById($id,$data){
        $data['updated_at'] = now();
        return Role::query()->where('id',$id)->update($data);
    }

}
